<title>清除缓存</title>
<style>
    .show-size{
        display: inline-block;
        font-size: 16px;
        position: relative;
        top: 5px;

    }
</style>

<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">主页</a>
        <a><cite>网站管理</cite></a>
        <a><cite>清除缓存</cite></a>
    </div>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">网站配置</div>
                <div class="layui-card-body">
                    <script type="text/html" template lay-url="/api/admin/cache/info" id="JW_WEBCONFIG_VIEW"
                            lay-done="renderClearCache(d)">
                        <div class="layui-form" id="layuiadmin-form-comment" lay-filter="layuiadmin-form-comment">
                            <div class="layui-form-item">
                                <label class="layui-form-label">临时文件</label>
                                <div class="layui-input-block">
                                    <input type="checkbox" name="temp" lay-skin="switch" lay-text="ON|OFF" value="1">
                                    <span class="layui-word-aux show-size">{{ computeSize(d.data.tempSize,2)}}</span>
                                </div>

                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">数据缓存</label>
                                <div class="layui-input-block">
                                    <input type="checkbox" name="cache" lay-skin="switch" lay-text="ON|OFF" value="1">
                                    <span class="layui-word-aux show-size">{{ computeSize(d.data.cacheSize,2)}}</span>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">日志文件</label>
                                <div class="layui-input-block">
                                    <input type="checkbox" name="log" lay-skin="switch" lay-text="ON|OFF" value="1">
                                    <span class="layui-word-aux show-size">{{ computeSize(d.data.logSize,2)}}</span>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">内存缓存</label>
                                <div class="layui-input-block">
                                    <input type="checkbox" name="memory" lay-skin="switch" lay-text="ON|OFF" value="1">
                                    <span class="layui-word-aux show-size"></span>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label"></label>
                                <div class="layui-input-block">
                                    <input class="layui-btn" id="submit" style="float: right" lay-filter="submit-clearCache" lay-submit
                                           type="button" value="执行操作">
                                </div>
                            </div>

                        </div>

                    </script>


                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function renderClearCache(d) {
        layui.use('web', layui.factory('web')).use(['admin', 'web', 'form'], function () {
            var form = layui.form
                , $ = layui.jquery
            ;
            form.render();

        })
    }
    var computeSize = function (size, decimal) {
        if (!size) return "0 B"
        if (void 0 === decimal && (decimal = 2), 0 === size) return "0 B";
        var n = decimal < 0 ? 0 : decimal, i = Math.floor(Math.log(size) / Math.log(1024));
        return parseFloat((size / Math.pow(1024, i)).toFixed(n)) + " " + ["B", "K", "M", "G", "T", "P", "E", "Z", "Y"][i]
    }

</script>